package com.ruoyi.controller;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.domain.Vo.WXResponse;
import com.ruoyi.service.WXService;
import com.ruoyi.utils.SimpleResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/wx")
@RestController
public class WXController {
    @Autowired
    private WXService wxService;

    @GetMapping("/openid/{code}")
    public SimpleResult openid(@PathVariable("code") String code) {
        WXResponse wxResponse = wxService.getWXOpenId(code);
        if (wxResponse != null){
            return SimpleResult.success(wxResponse, "获取openid成功");
        } else {
            return SimpleResult.error("获取openid失败");
        }
    }

}
